```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式系统降级机制解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .section-title {
            position: relative;
            display: inline-block;
        }
        .section-title:after {
            content: '';
            position: absolute;
            bottom: -8px;
            left: 0;
            width: 50%;
            height: 3px;
            background: linear-gradient(90deg, #667eea, #764ba2);
            border-radius: 3px;
        }
        .first-letter {
            font-size: 3.5em;
            line-height: 0.8;
            float: left;
            margin-right: 8px;
            font-weight: 700;
            color: #764ba2;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">分布式系统降级机制解析</h1>
            <p class="text-xl md:text-2xl mb-8 max-w-3xl mx-auto leading-relaxed opacity-90">
                深入探索Hystrix与Sentinel如何保障系统的高可用性
            </p>
            <div class="flex justify-center space-x-4">
                <a href="#hystrix" class="px-6 py-3 bg-white text-purple-700 rounded-full font-medium hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-shield-alt mr-2"></i>Hystrix
                </a>
                <a href="#sentinel" class="px-6 py-3 bg-transparent border-2 border-white text-white rounded-full font-medium hover:bg-white hover:text-purple-700 transition duration-300">
                    <i class="fas fa-fire-extinguisher mr-2"></i>Sentinel
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Hystrix Section -->
        <section id="hystrix" class="mb-20">
            <div class="flex items-center mb-10">
                <i class="fas fa-shield-alt text-3xl text-purple-600 mr-4"></i>
                <h2 class="text-3xl font-bold text-gray-800 section-title">Hystrix实现降级</h2>
            </div>
            
            <div class="flex">
                <div class="hidden md:block w-1/4 pr-8">
                    <div class="sticky top-24">
                        <div class="bg-white p-6 rounded-xl shadow-md">
                            <h4 class="font-bold text-lg mb-4 text-purple-700">Hystrix核心机制</h4>
                            <ul class="space-y-3">
                                <li class="flex items-center"><span class="w-2 h-2 bg-purple-500 rounded-full mr-2"></span> Fallback方法</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-purple-500 rounded-full mr-2"></span> 断路器</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-purple-500 rounded-full mr-2"></span> 请求缓存</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-purple-500 rounded-full mr-2"></span> 超时机制</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-purple-500 rounded-full mr-2"></span> 并发限制</li>
                            </ul>
                        </div>
                    </div>
                </div>
                
                <div class="w-full md:w-3/4">
                    <div class="mb-6">
                        <p><span class="first-letter">在</span>分布式系统中，服务间的调用可能会受到网络延迟、服务故障等各种因素的影响，为了保障系统的稳定性和可用性，Hystrix作为一种服务容错和降级的解决方案，为我们提供了一系列强大的降级机制。</p>
                    </div>
                    
                    <!-- Fallback -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-purple-700 flex items-center">
                            <i class="fas fa-life-ring mr-2"></i> Fallback方法
                        </h3>
                        <p class="text-gray-700">Hystrix允许我们在每个服务调用的命令中定义一个Fallback方法，当主逻辑执行失败或超时时，系统会自动降级到Fallback方法提供的备选逻辑。这种方式可以确保即使主服务不可用，系统也能够提供一定程度的服务。</p>
                    </div>
                    
                    <!-- Circuit Breaker -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-purple-700 flex items-center">
                            <i class="fas fa-bolt mr-2"></i> 断路器（Circuit Breaker）
                        </h3>
                        <p class="text-gray-700">Hystrix通过断路器来监控服务的状态，当服务的失败率达到一定的阈值时，断路器会打开，表示该服务不可用。在断路器打开的状态下，Hystrix会快速失败而不是等待超时，从而避免资源浪费。当服务恢复正常时，断路器会逐渐关闭，重新允许请求。</p>
                    </div>
                    
                    <!-- Request Cache -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-purple-700 flex items-center">
                            <i class="fas fa-database mr-2"></i> 请求缓存
                        </h3>
                        <p class="text-gray-700">Hystrix还提供了请求缓存的功能，可以避免重复执行相同的请求。当请求缓存命中时，Hystrix会直接返回缓存的结果，而不执行主逻辑，从而减轻服务压力，提高系统的响应速度。</p>
                    </div>
                    
                    <!-- Timeout -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-purple-700 flex items-center">
                            <i class="fas fa-clock mr-2"></i> 超时机制
                        </h3>
                        <p class="text-gray-700">Hystrix还支持设置超时时间，当服务调用超过指定的时间限制仍未返回结果时，Hystrix会自动触发降级操作，避免长时间等待导致系统资源浪费。</p>
                    </div>
                    
                    <!-- Concurrency -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-purple-700 flex items-center">
                            <i class="fas fa-users mr-2"></i> 并发限制
                        </h3>
                        <p class="text-gray-700">为了避免系统过载，Hystrix还支持设置并发限制，当并发请求达到一定数量时，Hystrix会拒绝新的请求并执行降级操作，从而保护系统免受过载影响。</p>
                    </div>
                    
                    <!-- Diagram -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6">
                        <div class="mermaid">
                            graph TD
                                A[服务请求] --> B{是否超时?}
                                B -->|是| C[执行Fallback]
                                B -->|否| D{断路器状态?}
                                D -->|打开| C
                                D -->|关闭| E[执行主逻辑]
                                E --> F{执行成功?}
                                F -->|是| G[返回结果]
                                F -->|否| H[计数器+1]
                                H --> I{失败率>阈值?}
                                I -->|是| J[打开断路器]
                                I -->|否| C
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Sentinel Section -->
        <section id="sentinel" class="mb-20">
            <div class="flex items-center mb-10">
                <i class="fas fa-fire-extinguisher text-3xl text-red-500 mr-4"></i>
                <h2 class="text-3xl font-bold text-gray-800 section-title">Sentinel实现降级</h2>
            </div>
            
            <div class="flex">
                <div class="hidden md:block w-1/4 pr-8">
                    <div class="sticky top-24">
                        <div class="bg-white p-6 rounded-xl shadow-md">
                            <h4 class="font-bold text-lg mb-4 text-red-600">Sentinel核心机制</h4>
                            <ul class="space-y-3">
                                <li class="flex items-center"><span class="w-2 h-2 bg-red-500 rounded-full mr-2"></span> 基于RT的降级</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-red-500 rounded-full mr-2"></span> 基于异常数的降级</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-red-500 rounded-full mr-2"></span> 熔断降级</li>
                                <li class="flex items-center"><span class="w-2 h-2 bg-red-500 rounded-full mr-2"></span> 限流降级</li>
                            </ul>
                        </div>
                    </div>
                </div>
                
                <div class="w-full md:w-3/4">
                    <div class="mb-6">
                        <p><span class="first-letter">在</span>微服务架构中，服务之间的调用可能会受到各种因素的影响，例如网络延迟、服务超载等。为了保障系统的稳定性和可用性，Sentinel作为一种流量控制和降级的解决方案，为我们提供了一系列强大的降级机制。</p>
                    </div>
                    
                    <!-- RT Degrade -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-red-600 flex items-center">
                            <i class="fas fa-tachometer-alt mr-2"></i> 基于RT的降级
                        </h3>
                        <p class="text-gray-700">Sentinel可以根据服务接口的响应时间（RT）来实现降级。当服务的响应时间超过预设的阈值时，Sentinel会自动降级该服务，拒绝新的请求并返回预设的降级响应，从而避免因服务响应过慢导致系统资源耗尽。</p>
                    </div>
                    
                    <!-- Exception Degrade -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-red-600 flex items-center">
                            <i class="fas fa-exclamation-triangle mr-2"></i> 基于异常数的降级
                        </h3>
                        <p class="text-gray-700">Sentinel还支持根据服务接口的异常数来实现降级。当服务接口的异常数超过预设的阈值时，Sentinel会自动触发降级操作，拒绝新的请求并返回预设的降级响应，防止异常频发导致系统崩溃。</p>
                    </div>
                    
                    <!-- Circuit Break -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-red-600 flex items-center">
                            <i class="fas fa-fire mr-2"></i> 熔断降级
                        </h3>
                        <p class="text-gray-700">Sentinel通过熔断机制来实现服务的降级。当服务的异常比例超过预设的阈值时，Sentinel会自动打开熔断器，拒绝新的请求并返回预设的降级响应。在熔断器打开的状态下，Sentinel会拒绝一段时间内的所有请求，从而保护系统免受异常影响。</p>
                    </div>
                    
                    <!-- Flow Control -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6 card-hover">
                        <h3 class="text-xl font-bold mb-4 text-red-600 flex items-center">
                            <i class="fas fa-sliders-h mr-2"></i> 限流降级
                        </h3>
                        <p class="text-gray-700">Sentinel还支持根据服务接口的请求量来实现降级。当服务的请求量超过预设的阈值时，Sentinel会自动进行限流，拒绝新的请求并返回预设的降级响应，避免服务过载导致系统崩溃。</p>
                    </div>
                    
                    <!-- Diagram -->
                    <div class="bg-white rounded-xl p-6 shadow-sm mb-6">
                        <div class="mermaid">
                            graph LR
                                A[请求进入] --> B{是否限流?}
                                B -->|是| C[拒绝请求]
                                B -->|否| D{RT是否超时?}
                                D -->|是| E[触发RT降级]
                                D -->|否| F{异常数超限?}
                                F -->|是| G[触发异常降级]
                                F -->|否| H{异常比例超限?}
                                H -->|是| I[触发熔断]
                                H -->|否| J[正常处理]
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Comparison Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">Hystrix vs Sentinel 对比分析</h2>
            <div class="bg-white rounded-xl shadow-sm overflow-hidden">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">特性</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Hystrix</th>
                            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sentinel</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">主要功能</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">服务容错和降级</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">流量控制、熔断降级、系统保护</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">实时监控</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">通过Hystrix Dashboard</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">内置实时监控和控制台</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">规则配置</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">代码配置</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">支持动态配置</td>
                        </tr>
                        <tr>
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">适用场景</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">服务间的隔离和降级</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">全链路流量控制和系统保护</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto max-w-5xl px-4 text-center">
            <p class="text-lg mb-2">技术小馆</p>
            <a href="http://www.yuque.com/jtostring" class="text-purple-300 hover:text-white transition duration-300">
                http://www.yuque.com/jtostring
            </a>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            fontFamily: 'Noto Sans SC, sans-serif',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```